import { app, BrowserWindow } from "electron";
import path from "path";

function createWindow() {
  const win = new BrowserWindow({
    width: 1400,
    height: 800,
    minHeight: 800,
    minWidth: 800,
    webPreferences: {
      preload: path.resolve(__dirname, "preload.js")
    },
  });
  win.webContents.openDevTools();

  win.loadURL("http://localhost:8080");
}

app.whenReady().then(() => {
  createWindow();

  app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0) {
      createWindow();
    }
  });
});

app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
  }
});